export const useAccount = defineStore('account', {
  state: () => {
    const data: {
      uInfo: any
      token: string
      count: number
    } = reactive({
      uInfo: {
        authLevel: 99,
      },
      token: '',
      count: 0,
    })

    async function logIn(loginInfo: { account: string; password: string }) {
      const token = 'TEST'
      Object.assign(data, { token })
    }

    async function logOut() {
      Object.assign(data, { token: '' })
    }

    // persist
    return {
      ...toRefs(data),
      logIn,
      logOut,
    }
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'XXXXXXX-ACCOUNT',
        storage: localStorage,
      },
    ],
  },
})
